Image Style
These modifiers are specifically designed for views that render images (e.g., system symbols, local or remote images). They control layout behavior, scaling, and rendering characteristics of the image content.
scaleToFit
Definition
Description
Scales the image proportionally to fit within its parent container. The image's aspect ratio is preserved, and the entire image will be visible. Any remaining space in the container is left empty.
Equivalent to:
Behavior
- Resizes the image without cropping
- Preserves the original width-to-height ratio
- May introduce padding if aspect ratios do not match
Example
scaleToFill
Definition
Description
Scales the image proportionally to completely fill its parent container. The image's aspect ratio is preserved, but the image may be cropped to fit.
Equivalent to:
Behavior
- Image fills the entire container
- Maintains aspect ratio
- Portions of the image may be clipped
Example
aspectRatio
Definition
Description
Constrains the view’s dimensions to a specific width-to-height ratio, and determines how the image should be resized (fit or fill).
value: A numeric aspect ratio (e.g.16 / 9) ornullto preserve the original image’s ratio.contentMode:"fit"ensures the entire image fits within the view;"fill"ensures the view is fully filled, potentially cropping the image.
Example: Set aspect ratio to 3:2 and fit
Example: Use original aspect ratio and fill the space
imageScale
Definition
Description
Sets the rendering size of symbol-based images (SF Symbols). This modifier does not affect the layout size, only the visual scale of the symbol image.
"small": Reduced symbol size"medium": Default scale"large": Enlarged symbol rendering
Note: This modifier only applies to system symbol images created with
systemName.
